﻿using System;
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{

    class Creationandexchangeof3DmodelsToolholdersforindexableinserts17
    {
        public static void _Creationandexchangeof3DmodelsToolholdersforindexableinserts17(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            refin.Linetype = Linetype.Dashed;
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            centre.Linetype = Linetype.DashDot;
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            double scale = 3; //放大系数


            double h = 12;
            double b = 12;
            double dconms = 12;
            double l3 = 9.52;
            double wta = 16;
            double wf = 22;
            double lf = 80;
            double lh = 22.25;
            double s = 2;
            double kapr = 60;
            double lfa = l3 * Math.Cos(kapr * pi / 180);
            double oal = lf + lfa;
            double wfa = l3 * Math.Sin(kapr * pi / 180);

            //坐标
            Vector2 v59 = new Vector2(0,0);
            Vector2 v61 = new Vector2(v59.X + oal, v59.Y -dconms / 4.191);
            Vector2 v60 = new Vector2(v61.X - oal / 24.856, v59.Y);
            Vector2 v62 = new Vector2(v59.X + lf, v60.Y - wf);
            Vector2 v63 = fun.Polar(v62, kapr * pi / 180, l3);
            Vector2 v64 = fun.Polar(v63, (90 + kapr) * pi / 180, l3);
            Vector2 v65 = fun.Polar(v62, (90 + kapr) * pi / 180, l3);
            Vector2 v66 = fun.Polar(v65, kapr * pi / 180, l3 / 11.371);
            Vector2 v67 = new Vector2(v63.X - lh, v59.Y - b);
            Vector2 v68 = new Vector2(v59.X, v67.Y);
            Vector2 v69 = new Vector2(v61.X, v63.Y + (v63.X - v61.X) * Math.Tan((90 - kapr) * pi / 180));
            Vector2 v70 = fun.Polar(v62, (kapr + 45) * pi / 180, l3 / 3.618);
            Vector2 v71 = fun.Polar(v70, kapr * pi / 180, l3 - l3 / 3.618 * Math.Sin(45 * pi / 180) * 2);
            Vector2 v72 = fun.Polar(v71, (90 + kapr) * pi / 180, l3 - l3 / 3.618 * Math.Sin(45 * pi / 180) * 2);
            Vector2 v73 = fun.Polar(v70, (90 + kapr) * pi / 180, l3 - l3 / 3.618 * Math.Sin(45 * pi / 180) * 2);
            Vector2 v74 = fun.Polar(v62, (kapr + 45) * pi / 180, l3 / Math.Sin(45 * pi / 180) / 2);
            Vector2 v75 = new Vector2(v61.X, v60.Y - b / 2);
            Vector2 v76 = new Vector2(v57.X, v75.Y);



            //定义格式，路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }

    }
}
